<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>登录页面 - 时光草堂</title>
    <link rel="icon" href="favicon.ico" type="image/ico">
    <meta name="keywords" content="时光草堂">
    <meta name="description" content="时光草堂是一个后台管理系统的HTML模板，基于Bootstrap v4.4.1。">
    <meta name="author" content="青青">
    <link href="/static/css/login.css" rel="stylesheet">
    <style>
        .login-form .has-feedback {
            position: relative;
        }
        .login-form .has-feedback .form-control {
            padding-left: 36px;
        }
        .login-form .has-feedback .mdi {
            position: absolute;
            top: 0;
            left: 0;
            right: auto;
            width: 36px;
            height: 36px;
            line-height: 36px;
            z-index: 4;
            color: #dcdcdc;
            display: block;
            text-align: center;
            pointer-events: none;
        }
        .login-form .has-feedback.row .mdi {
            left: 15px;
        }
        .login-form .form-group:last-child,
        .login-right p:last-child {
            margin-bottom: 0px;
        }
        .login-right {
            background: #67b26f!important;
            background: -moz-linear-gradient(45deg,rgb(103 178 111 / 60%) 0,#4ca2cd 100%)!important;
            background: -webkit-linear-gradient(45deg,#67b26f59 0,#4ca2cd 100%)!important;
            background: linear-gradient(45deg,#67b26f59 0,#4ca2cd 100%)!important;
            filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#67b26f', endColorstr='#4ca2cd', GradientType=1 )!important;
        }
        .login-box {
            max-width: 700px;
        }
        .login-right {
            max-width: 50%;
        }
        .text-white{color: #fff}
        .form-control {
            display: block;
            width: 100%;
            height: calc(1.5em + .75rem + 2px);
            padding: .375rem .75rem;
            font-size: 1rem;
            font-weight: 400;
            line-height: 1.5;
            color: #495057;
            background-color: #fff;
            background-clip: padding-box;
            border: 1px solid #ced4da;
            border-radius: .25rem;
            transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;

            font-size: 14px;
            height: calc(1.5em + .75rem + 3px);
            border-color: #F2F3F3/*rgba(77, 82, 89, 0.07)*/;
            -webkit-border-radius: 2px;
            border-radius: 2px;
            color: #8b95a5;
            -webkit-transition: 0.2s linear;
            transition: 0.2s linear;
        }
        .custom-control-label {
            position: relative;
            margin-bottom: 0;
            vertical-align: top;
        }

        label {
            display: inline-block;
            margin-bottom: .5rem;
        }
        html,body{
            height: 100%;
        }
        .body-bg{
            background-image: url(/static/images/login-bg-3.jpg);
            background-size: cover;
            background-repeat: no-repeat;
            background-position: center;
        }

        @keyframes rotateAlbumArt {
            0% {
                -webkit-transform: rotateZ(0);
                transform: rotateZ(0);
            }

            100% {
                -webkit-transform: rotateZ(360deg);
                transform: rotateZ(360deg);
            }
        }

        .play{
            animation: rotateAlbumArt 3s linear 0s infinite forwards;
            -webkit-animation: rotateAlbumArt 3s linear 0s infinite forwards;
        }

    </style>
</head>

<body class="center-vh body-bg" >
<div class="bg-translucent p-2">
    <div class="flex-box bg-white login-box">
        <div class="login-left p-5">
            <div class="text-center mb-3 d-sm-none" style="width: 165px;height: 165px;margin-left: auto; margin-right: auto;" >
                <a href="#"> <img style="border-radius: 50%;width: 100%;height: 100%" id="m"  src="/static/images/avatar.jpg"> </a>
            </div>
            <form id="form" action="#!" method="post" class="login-form" onsubmit="return false">
                <div class="form-group has-feedback">
                    <span class="mdi mdi-account" aria-hidden="true"></span>
                    <input type="text" class="form-control" autocomplete="false" id="userName" name="userName" value="admin" placeholder="用户名">
                </div>

                <div class="form-group has-feedback">
                    <span class="mdi mdi-lock" aria-hidden="true"></span>
                    <input type="password" class="form-control" id="passWord" name="passWord" value="123123" placeholder="密码">
                </div>

                <div class="form-group has-feedback row">
                    <div class="col-7">
                        <span class="mdi mdi-check-all form-control-feedback" aria-hidden="true"></span>
                        <input type="text" name="captcha" class="form-control" placeholder="验证码">
                    </div>
                    <div class="col-5 text-right">
                        <img src="/sso/getCaptcha"class="pull-right" id="captcha" style="cursor: pointer;height: 100%;width: 100%" onclick="getCode(this)" title="点击刷新" alt="加载中..">
                    </div>
                </div>

                <div class="form-group">
                    <div class="custom-control custom-checkbox">
                        <input type="checkbox" class="custom-control-input" id="rememberme">
                        <label class="custom-control-label not-user-select" for="rememberme">5天内自动登录</label>
                    </div>
                </div>

                <div class="form-group">
                    <button class="btn btn-block btn-primary" type="submit" onclick="login()">立即登录</button>
                </div>
            </form>
        </div>
        <div class="login-right p-5 d-none d-sm-block">
            <audio style="display: none;" id="audio" src="/static/images/dadada.mp3" controls autoplay preload="auto">
                <p class="text-white">你的浏览器版本太低了</p>
            </audio>
            <p class="text-white">天下英雄出我辈，一如江湖岁月催</p>
            <p class="text-white">皇图霸业谈笑中，不胜人间一场醉</p>
            <p class="text-white">提剑跨骑挥鬼雨，白骨如山鸟惊飞</p>
            <p class="text-white">尘世如潮人如水，只叹江湖几人回</p>
            <img src="/static/images/dadada.gif" id="ddd" style="width: 15em;display: none">
        </div>

    </div>
</div>
<script type="text/javascript" src="/static/js/jquery-3.5.1.js"></script>
<script type="text/javascript" src="/static/js/jquery.cookie.js"></script>
<script type="text/javascript">

    function login(){
        $.ajax({
            type: "POST",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            url: "/sso/user/login" ,
            data: $('#form').serialize(),
            success: function (res) {
                if (res.code === 0) {
                    console.log(res)
                    // window.location.href = "http://127.0.0.1:8081";
                    window.location.href = "http://159.75.74.174:8081";
                }
                else{
                    alert(res.data)
                }
            },
            error : function() {

                getCode()
            }
        });
    }

    function getCode(){
        document.getElementById("captcha").src = '/sso/getCaptcha?r='+new Date().getTime();
    }

    $(function (){
        let bgArray = ['/static/images/login-bg-3.jpg','/static/images/bg2.jpg']
        var body = $("body")
        let len = bgArray.length;
        let i = 0

        //加载完成执行一个定时器 4s执行一次
        setInterval(function (){
            if (i>=len){
                i = 0
            }
            let bg = bgArray[i];
            body.css("background-image","url("+bg+")")
            // body.eq(0).stop().fadeIn(0).siblings().stop().fadeOut(3000)
            ++i
        },4000)

        var audio = new Audio("/static/images/dadada.mp3");
        $("#m").click(function (){

            //如果是暂停中 就播放
            if (audio.paused){
                audio.play()
                $("#m").addClass("play")
                $("#ddd").fadeIn(2000)
            }
            else{
                $("#m").removeClass("play")
                $("#ddd").fadeOut(2000)
            }

            audio.addEventListener('ended',function(){
                $("#m").removeClass("play");
                $("#ddd").fadeOut(3000)
            },false);

        })
    })

</script>
</body>
</html>
